/**
 *
 */
package st.yushao.restaurant.fw;

import st.yushao.restaurant.common.SystemContext;

import com.opensymphony.xwork2.ActionSupport;

/**
 * @author st.yushao
 *
 */
public abstract class AbstractBaseAction extends ActionSupport {

    protected interface KEYS {
        String CUR_USER = "uvo";
        String CUR_REST_KEY = "cur_rest";
        String CUR_TABLE_KEY = "cur_table";
        String FROM_PAGE = "from_page";
    }

    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = -361986604670087969L;

    /**
     * the ID of last page;
     */
    private String fromPage;

    /**
     * the mode of current page;
     */
    private String mode;

    /**
     * prepare logic method
     */
    protected void preLogic() {
        return;
    }

    /**
     * main logic
     * @return action path
     */
    public abstract String doExecute();

    /**
     * deal with sth after the doExecute method is called
     */
    protected void postLogic() {
        return;
    }

    protected int getRestId() {
        return SystemContext.getSaVO().getRestId();
    }
    /**
     * logic entrance
     * @return action path
     */
    public String execute() {
        preLogic();
        String actionPath = doExecute();
        postLogic();
        return actionPath;
    }

    public String getFromPage() {
        return fromPage;
    }

    public void setFromPage(String fromPage) {
        this.fromPage = fromPage;
    }

    /**
     * @return the mode
     */
    public String getMode() {
        return mode;
    }

    /**
     * @param mode the mode to set
     */
    public void setMode(String mode) {
        this.mode = mode;
    }
}
